package com.alwvfhp.tools.Powershell.thread;

/**
 *<title>FlowService<title>
 *<pre>
 *在规定的时间未完成，强制关闭
 *</pre>
 *Author : sujian
 *Date   : 2014年8月12日
 */
public class ManagerThread implements Runnable {
	private Thread thread;
	private Integer period;
	public ManagerThread(Thread thread,Integer period) {
		this.thread=thread;
		this.period=period;
	}
	@Override
	public void run() {
		try {
			int count=this.period/1000;
			while((count--)>0){
				Thread.sleep(1000);
				if(!thread.isAlive())break;
			}
			if(thread.isAlive())thread.destroy();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
